#!/usr/bin/expect -f
#用途:远程执行一条任务
set user [lindex $argv 0]
set host [lindex $argv 1]
set password [lindex $argv 2]
set cmd [lindex $argv 3]

spawn ssh $user@$host $cmd
#spawn $cmd
set timeout 300
expect "$user@$host's password:"
set timeout 300		
send "$password\r"
set timeout 300	
send "exit\r"
expect eof
